package org.bookie.model;

import java.util.Date;

/**
 * Class modelling a period. 
 */
public class Period {
	/**Start date*/
	private Date start;
	/**End date*/
	private Date end;
	
	/**
	 * Creates a period.
	 */
	public Period(){}
	
	/**
	 * Get end date
	 * @return instance of Date
	 */
	public Date getEnd() {
		return end;
	}
	
	/**
	 * Set end date 
	 * @param end date to set
	 */
	public void setEnd(Date end) {
		this.end = end;
	}
	
	/**
	 * Get start date
	 * @return instance of Date
	 */
	public Date getStart() {
		return start;
	}
	
	/**
	 * Set start date
	 * @param start date to set
	 */
	public void setStart(Date start) {
		this.start = start;
	}
	
	/**
	 * Get if the period is valid. 
	 * @return <true> if start date is before or equal end date. Otherwise <false>.
	 */
	public boolean isValid(){
		if(null==getStart() || null==getEnd()){
			return true;
		}
		if(getEnd().before(getStart())){
			return false;
		}
		return true;
	}
}
